<?php $request = sfContext::getInstance()->getRequest(); ?>
<?php include_partial('field/media', array('request'=>$request, 'field'=>$field)); ?>

<script type="text/javascript">
  $(document).ready(function() {
    
    $("#<?php echo $id; ?>").uploadify({
      'uploader'  : '/external/uploadify/uploadify.swf',
      'script'    : '/external/uploadify/uploadify.php',
      'cancelImg' : '/external/uploadify/cancel.png',
      'auto'      : false,
      'folder'    : '<?php echo $folder; ?>',
      'multi'     : '<?php echo $multi; ?>'
    });
    
    $("#<?php echo $id; ?>-wrapper ul").sortable({
      update: function(event, ui)
        {
            $.post(tableUrl + 'form/media_set_order', {
              'order': $(this).sortable("toArray"),
              'table': '<?php echo $field['tab']; ?>'
            })
        }
    });
       
  });
</script>